﻿@model RH.Web.ViewModels.ContactViewModel
@using RH.Web.Utility;
@using RH.Common.Extensions;
@{
    String pageTitle = "Edit Contact";
    if(Model.ID == 0){
        pageTitle = "Add Contact";
    }
    ViewBag.Title = Html.GetPageTitle(pageTitle);
    bool _IsSaved = TempData[AppConstants.ViewDataKeys.SAVED] == null ? false : TempData[AppConstants.ViewDataKeys.SAVED].ToString().ToBoolean();
    bool _IsAdded = TempData[AppConstants.ViewDataKeys.ADDED] == null ? false : TempData[AppConstants.ViewDataKeys.ADDED].ToString().ToBoolean();
    //bool _IsRegistrationMode = ViewBag.IsRegistrationMode != null && ViewBag.IsRegistrationMode ? true : false;
    //bool _CompanyName = ViewBag.CompanyName != null ? ViewBag.CompanyName : false;
    //bool _Email = ViewBag.Email != null && ViewBag.IsRegistrationMode ? true : false;
    
    //String heading = pageTitle;
    //if(_IsRegistrationMode){
    //    pageTitle = "Create Your Store.";
    //    Layout = "~/Views/Shared/_Layout.cshtml";
    //}
    if (Model.Address == null)
    {
        Model.Address = new RH.Web.ViewModels.AddressViewModel();
    }
    if(UserInfo.IsCompanyUser){
        ViewData[AppConstants.ViewDataKeys.SELECTED_MENU] = CompanyMenu.Contacts;
    }
}
<div class="rh-page-heading">
    <h1>@pageTitle</h1>
    <div>Manage contact/employee information of your company.</div>       
</div>
@using (Html.BeginForm()) {
    @Html.ValidationSummary(false)    
    <div class="rh-page-content">
        @if (Model == null)
        {
            @: @Html.ErrorMessageBox("Sorry! Requested Contact was not found for edit.")
        }
        else
        {
            if (_IsAdded)
            {
                @: @Html.SuccessMessageBox("Contact added successfully.", "Congrats!")
            }
            else if (_IsSaved)
            {
                @: @Html.SuccessMessageBox("Contact Saved Successfully.")
            }
        
            @Html.HiddenFor(model => model.ID)        
            @Html.HiddenFor(model => model.CompanyID)        
            @Html.HiddenFor(model => model.IsDeleted)        
            @Html.HiddenFor(model => model.AddressID)
            @Html.HiddenFor(model => model.User.IsActive)
            @Html.HiddenFor(model => model.User.GroupID)
            @*Left Column Start*@
            <div class="col-md-6 rh-gridfix">
                <div class="rh-group-title">Address Information</div>
                @Html.EditorFor(model => model.Address)
                <div class="rh-button-container">
                    <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-floppy-disk"></i> Save</button>
                    <a href="@Url.PrivateUrl("List", "Contact")" class="btn btn-default"><i class="glyphicon glyphicon-arrow-left"></i> Back to List</a>
                </div>
            </div>
        
            @*Left Column Start*@

            @*Right Column Start*@
            <div class="col-md-6 rh-gridfix">
                <div class="rh-group-title">General Information</div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Name)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.Gender)
                </div>
                <div class="editor-field">
                    @Html.DropDownListFor(model => model.Gender, BindSelectList.Gender())
                    @*@Html.EditorFor(model => model.Gender)*@
                    @Html.ValidationMessageFor(model => model.Gender)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.DateOfBirth)
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.DateOfBirth, new { @class = "datepicker" })
                    @Html.ValidationMessageFor(model => model.DateOfBirth)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.IsActive)
                </div>
                <div class="editor-field">
                    @Html.RadioButtonFor(model => model.IsActive, "true", new { id = "rdnIsActive_1" }) <label for="rdnIsActive_1">Yes</label>
                    @Html.RadioButtonFor(model => model.IsActive, "false", new { id = "rdnIsActive_0" }) <label for="rdnIsActive_0">No</label>
                    @Html.ValidationMessageFor(model => model.IsActive)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.FatherName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.FatherName)
                    @Html.ValidationMessageFor(model => model.FatherName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.MotherName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.MotherName)
                    @Html.ValidationMessageFor(model => model.MotherName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.SpouseName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.SpouseName)
                    @Html.ValidationMessageFor(model => model.SpouseName)
                </div>
            </div>
            @*Right Column End*@
        }
    </div>    
}
@section PageHeadSection{
    @Styles.Render(Bundles.jQueryUIDatePickerCSS)
}
@section JavaScriptPlaceholder
{
    @Scripts.Render(Bundles.jQueryValidate, Bundles.jQeuryUIJS)
    @Html.Partial("_DatePicker", "1970:2000")
}


